﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace SetupLauncher.Domain.Util
{
    public static class ExecuteProgram
    {
        public static void Run(string path, bool waitForExit)
        {
            Run(path, string.Empty, waitForExit);
        }

        public static void Run(string path, string args)
        {
            Run(path, args, false);
        }

        public static void Run(string path, string args, bool waitForExit)
        {
            ProcessStartInfo processInfo;
            Process process;

            processInfo = new ProcessStartInfo(path, args);
            processInfo.CreateNoWindow = true;
            processInfo.UseShellExecute = false;
            process = Process.Start(processInfo);
            if (waitForExit)
            {
                process.WaitForExit();
                process.Close();
            }
        }
    }
}
